home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / dnssd / servicebase.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.3 KB  |  122 lines

  1. /* This file is part of the KDE project
  2.  *
  3.  * Copyright (C) 2004 Jakub Stachowski <qbast@go2.pl>
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Library General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * Library General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Library General Public License
  16.  * along with this library; see the file COPYING.LIB.  If not, write to
  17.  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.  * Boston, MA 02110-1301, USA.
  19.  */
  20.  
  21. #ifndef DNSSDSERVICEBASE_H
  22. #define DNSSDSERVICEBASE_H
  23.  
  24. #include <qmap.h>
  25. #include <ksharedptr.h>
  26.  
  27. class QString;
  28. class QDataStream;
  29. namespace DNSSD
  30. {
  31. class ServiceBasePrivate;
  32.  
  33. /**
  34. This class is used to carry information about service. It can be remote, local,
  35. metaservice or domain. Metaservice has only type and domain - it means that
  36. services of given type are present in given domain.
  37. @short Describes any type of service.
  38. @author Jakub Stachowski
  39.  */
  40. class KDNSSD_EXPORT ServiceBase : public KShared
  41. {
  42. public:
  43.     typedef KSharedPtr<ServiceBase> Ptr;
  44.  
  45.     /**
  46.     @param name Service name - empty for metaservices
  47.     @param type Service type - empty for domains
  48.     @param domain Domain name
  49.     @param host Host name
  50.     @param port Port number
  51.      */
  52.     ServiceBase(const QString& name=QString::null,const QString& type=QString::null,
  53.             const QString& domain=QString::null, const QString& host=QString::null,
  54.             unsigned short port=0);
  55.  
  56.     virtual  ~ServiceBase();
  57.  
  58.     /**
  59.     Returns name of service. This is empty for metaservices
  60.      */
  61.     const QString& serviceName() const;
  62.  
  63.     /**
  64.     Returns type of service. It always in format _sometype._udp or _sometype._tcp and
  65.     it is empty for domains.
  66.      */
  67.     const QString& type() const;
  68.  
  69.     /**
  70.     Returns domain that given service belongs to. It is "local." for link-local services.
  71.      */
  72.     const QString& domain() const;
  73.  
  74.     /**
  75.     Returns hostname. It is only valid for local and resolved remote services.
  76.      */
  77.     const QString& hostName() const;
  78.  
  79.     /**
  80.     Returns port number. It is only valid for local and resolved remote services.
  81.      */
  82.     unsigned short port() const;
  83.  
  84.     /**
  85.     Returns read only map of text properties.  It is only valid for local and resolved remote services.
  86.      */
  87.     const QMap<QString,QString>& textData() const;
  88.  
  89. protected:
  90.     QString m_serviceName;
  91.     QString m_type;
  92.     QString m_domain;
  93.     QString m_hostName;
  94.     unsigned short m_port;
  95.  
  96.     /**
  97.     Map of TXT properties
  98.      */
  99.     QMap<QString,QString> m_textData;
  100.     /**
  101.     Encode service name, type and domain into string that can be used as DNS-SD PTR label
  102.      */
  103.     QString encode();
  104.     /**
  105.     Decode PTR label returned by DNS resolver into service name, type and domain. It also
  106.     handles special cases - metaservices and domains.
  107.      */
  108.     void decode(const QString& name);
  109.  
  110.     friend KDNSSD_EXPORT QDataStream & operator<< (QDataStream & s, const ServiceBase & a);
  111.     friend KDNSSD_EXPORT QDataStream & operator>> (QDataStream & s, ServiceBase & a);
  112.  
  113.     virtual void virtual_hook(int, void*);
  114. private:
  115.     ServiceBasePrivate* d;
  116.  
  117. };
  118.  
  119. }
  120.  
  121. #endif
  122.